'TO DO:
'Set up instakilling and venom-shoot



def temp 55
def orig 56


'Veggie is determined by memloc (chlr)

def stat 21
def tstat 24

def veg 1001
def ally 1002
def lilen 1003
def bigen 1004
def ensee 1005

'Types of venom and instakills
'Not all tree snails produce venom, and not all instakill
'Loc of affected sysvars stored in type
'0 is none

def vtype 971
def liltype 972
def bigtype 973

'Venom targets
'Sexrepro
'Shoot
'Shootval
'Mrepro
'Fixpos
'Aim

'Instakill targets
'Body-dependent (factored into enemy recog)
'Fer lil ones
'Fdbody
'Shootval
'Strvenom

'Fer fatties
'Fixpos
'Shoot
'Shootval

start
.orig dec
*.thisgene .delgene store
stop

start
*.myup *.trefup !=
*.trefbody 50 >
and
.bigen .tstat store
clearbool
*.myup *.trefup !=
*.trefbody 50 <=
and
.lilen .tstat store
clearbool
*.tmemloc 2 >
.veg .tstat store
stop

else
0 .tstat store
stop

start
*.memloc 2 >
.veg .stat store
*.myup *.refup !=
*.memloc 0 =
.ensee .stat store
*.myup *.refup =
.ally .stat store
stop

else
.ally .stat store
stop

'=======================================================
'*.robage 0 =
'=======================================================
cond
*.robage 0 =
start
140 .eye6width store
280 .eye7width store
280 .eye8width store
280 .eye9width store
-68 .eye1dir store
-68 .eye2dir store
-68 .eye3dir store
-68 .eye4dir store
-68 .eye5dir store
-140 .eye6dir store
317 .eye7dir store
634 .eye8dir store
970 .eye9dir store
-2 .focuseye store
2 .strpoison store
.chlr .tmemloc store
.chlr .memloc store
stop

cond
20 rnd 3 =
*.orig 0 !=
xor
*.robage 15 <=
start
.deltie inc
5 rnd ++ .temp store
*.temp 1 =
.sexrepro .vtype store
99 .venval store
clearbool
*.temp 2 =
.shoot .vtype store
-2 .venval store
clearbool
*.temp 3 =
.shootval .vtype store
-31000 .venval store
clearbool
*.temp 4 =
.mrepro .vtype store
99 .venval store
clearbool
*.temp 5 =
.fixpos .vtype sore
-32000 32000 rnd .venval store
clearbool
*.temp 6 =
.setaim .vtype store
'Will be set per-cyc
clearbool
2 rnd ++ .temp store
*.temp 1 =
.fdbody .liltype store
clearbool
*.temp 2 =
.shoot .liltype store
clearbool
*.temp 3 =
.shootval .liltype store
clearbool
2 rnd ++ .temp store
*.temp 1 =
.fixpos .liltype store
clearbool
*.temp 2 =
.shoot .liltype store
clearbool
*.temp 3 =
.shootval .liltype store
clearbool
stop

'========================================================
'Aiming
'========================================================
cond
*.eye1 *.eye2 *.eye3 *.eye4 *.eye5 add add add add 0 =
start
157 .aimdx store
stop

cond
*.stat .ally =
start
157 .aimsx store
stop

cond
*.eye3 0 =
*.eye4 0 !=
start
34 .aimdx store
stop
cond
*.eye3 0 =
*.eye2 0 !=
start
-34 .aimdx store
stop
cond
*.eye3 0 =
*.eye5 0 !=
start
68 .aimdx store
stop
cond
*.eye3 0 =
*.eye1 0 >
start
-68 .aimdx store
stop

'=====================================================
'Body and Stuff
'=====================================================
cond
*.vtype .setaim =
*.venval *.aim !=
start
*.aim .venval store
stop

cond
*.nrg 2000 >
*.shell 2000 <=
*.robage 2 mod 0 =
start
100 .mkshell store
stop

cond
*.nrg 2000 >
*.venom 5000 <=
*.robage 2 mod 1 =
start
100 .strvenom store
stop

cond
*.body 20 >
*.nrg 500 <=
start
100 .fdbody store

cond
*.nrg 1000 >
*.robage 2 >
start
100 .strbody store
stop

cond
*.body 1000 >=
start
100 .fdbody store
stop

cond
*.numties 0 >
*.nrg 2000 >
start
100 .mkslime store
stop

cond
*.nrg 2000 >
start
37 .repro store
stop

cond
*.waste 100 >
start
*.waste .shootval store
-4 .shoot store
stop

'===========================================================
'Tieing

cond
*.stat .ensee =
*.stat .veg =
or
*.numties 0 =
*.eyef 0 >
start
*.refxpos *.refypos angle .setaim store
*.velsx .dx store
*.eyef 50 >
*.maxvel .up store
.tie inc
*.stat .veg = and
*.velsx .dx store
*.refvelup 15 add *.maxvel ceil 0 floor .up store
.fixpos .shoot store
1 .shootval store
stop

cond
*.tstat .con =
*.myeye *.trefeye =
or 
start
*.tiepres .deltie store
stop

'===========================================================
'Feeding
'Lifted from BlueOnBlue
cond
*.eyef 0 >
*.myup *.refup !=
*.stat .ally !=
or
start
*.refxpos *.refypos angle .setaim store
*.refxpos *.refypos angle *.aim sub .aimshoot store
*.refxpos *.refypos dist 700 div *.maxvel mult *.refvel add 0 floor *.maxvel ceil .up store
*.veldx .sx store
clearbool
'This is a rather complex logic gate. Must check for errors.
*.stat .veg =
*.refnrg 1000 >
and 
*.eyef 50 >=
*.stat .ensee =
and
xor
-6  .shoot store
*.nrg 50 div 20 floor 1000 ceil .shootval store
stop

'===========================================================
'Molest

'This is to keep other bots from kiling your target
cond
*.in1 1221 =
*.vtype .sexrepro !=
start
0 .shoot store
618 .aimsx store
stop

'MOLEST! Heeheeheee!
cond
*.eyef 50 >=
start
*.stat .veg =
*.vtype .sexrepro =
-8 *.robage 2 mod .shoot mult store
-3 *.robage 2 mod 0 sub sgn abs -- abs .shoot mult store
*.venom 5 div ++ .shootval store
.out1 .tieloc store
1221 .tieval store
stop
 
'==============================================================================================
'Defences

start
0 .fixpos store
*.shoot -2 sub sgn abs -- abs .shoot mult store
*.sexrepro 0 sub sgn abs .sexrepro mult store
*.mrepro 0 sub sgn abs .mrepro mult store
*.numties 0 >
*.tstat .veg !=
*.robage 1 != and
*.tiepres .tienum store
0 .shoot store
0 .shootval store
100 .mkslime store
stop

cond
*.shflav -7 =
start
*.mkvirus .delgene store
100 .mkslime store
stop

cond
*.shflav -2 !=
*.shflav 0 !=
start
*.shang .aimshoot store
-3 .shoot store
1 rnd 1 =
-6 .shoot store
32 .shootval store
clearbool
0 .shflav store
stop

'============================================================
'Slaughter!
'============================================================

'==============================
'Use venom where applicable
cond
*.eyef 0 >
*.stat .ensee =
start
-3 .shoot store
*.venom 2 div .shootval store
stop
'==============================
'Set up "venom cloud" if I have both enough energy and venom
cond
*.venom 500 >
*.nrg 1000 >
start
-3 .shoot store
1221 rnd .aimshoot store
stop

'=============================
'Yay! Instakills!
'Operates on type and size of bot.

cond
*.stat .lilen =
start
*.liltype .tieloc store
99 .tieval store
*.liltype .shootval =
-31999 .tieval store
stop

cond
*.stat .lilen =
start
*.liltype .tieloc store
-31999 .tieval store
*.liltype .shoot =
-2 .tieval store
stop
